<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *战队管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$manage_op=array('confirm','cancel','agree','disagree');
if(in_array($_RQ['op'],$manage_op)){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择战队！','error');
	}
}
$return=array();
$tabs=array(
	array('op'=>'list','title'=>'战队列表'),

	
);
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','title','avatar','image','headsid','remark','status','createtime');
	$list=pdo_getslice('jy_aligroup_groups_corps',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$heads=pdo_get('jy_weishop_members',array('id'=>$item['headsid'],'uniacid'=>$_SESSION['uniacid']));
			$item['headsname']=$heads['nickname'];
			$item['realname']=$heads['realname'];
			$item['headsavatar']=$heads['avatar'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'title','title'=>'战队名称','type'=>'string'),
			array('name'=>'image','title'=>'战队宣传图','type'=>'image'),
			array('name'=>'avatar','title'=>'队友头像设置','type'=>'image'),
			array('name'=>'headsname','title'=>'团长昵称','type'=>'string'),
			array('name'=>'realname','title'=>'团长姓名','type'=>'string'),
			array('name'=>'headsavatar','title'=>'团长头像','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'战队名称','type'=>'string','width'=>15),
			array('name'=>'headsname','title'=>'团长昵称','type'=>'string','width'=>15),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
